﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="data_role_edit.aspx.cs" Inherits="ByteSite.Web.admin.form.data_role_edit" ValidateRequest="false" %>
<%@ Import namespace="ByteSite.Common" %>

<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>编辑列表</title>
<meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0,initial-scale=1.0,user-scalable=no" />
<meta name="apple-mobile-web-app-capable" content="yes" />
<link rel="stylesheet" type="text/css" href="../../scripts/artdialog/ui-dialog.css" />

<link rel="stylesheet" type="text/css" href="../skin/default/style.css" />
<link href="../skin/uikit/css/uikit.min.css" rel="stylesheet" />
<script type="text/javascript" src="../skin/uikit/js/uikit.min.js"></script>
<script type="text/javascript" src="../skin/uikit/js/uikit-icons.min.js"></script>
<script type="text/javascript" charset="utf-8" src="../../scripts/jquery/jquery-1.11.2.min.js"></script>
<script type="text/javascript" charset="utf-8" src="../../scripts/jquery/Validform_v5.3.2_min.js"></script>
<script type="text/javascript" charset="utf-8" src="../../scripts/artdialog/dialog-plus-min.js"></script>
<script type="text/javascript" src="../../scripts/xm-select/xm-select.js"></script>
<script type="text/javascript" charset="utf-8" src="../js/common.js"></script>
<script type="text/javascript" charset="utf-8" src="../js/laymain.js"></script>
<script type="text/javascript">
    $(function () {
        //初始化表单验证
        $("#form1").initValidform();
        //添加按钮(点击绑定)
        $("#itemAddButton").click(function () {
            showChannelDialog();
        });
        
    });
    function AddWhere(row) {
        if (row == "row") {
            var column = $("#ddlColumn").val();
            var whereType = $("#ddlType").val();
            var value = $("#txtValue").val();

            var jsonObj = eval("(" + $("#hidWhereJson").val() + ")");

            var obj = { column: column, type: whereType, value: value };
            var result = true;
            for (var i = 0; i < jsonObj.length; i++) {
                if (jsonObj[i].column == column && jsonObj[i].type == whereType && jsonObj[i].value == value) {
                    result = false;
                }
            }
            if (result) {
                jsonObj.push(obj);
                $("#datatable").append("<tr class=\"data\"><td>" + column + "</td><td>" + whereType + "</td><td>" + value + "</td><td>" + "<a href=\"javascript:;\" onclick=\"DeleteWhere('" + column + "','" + whereType + "','" + value + "')\">×</a>" + "</td></tr>");
                $("#hidWhereJson").val(JSON.stringify(jsonObj));
            }
        } else if (row == "(") {

        } else if (row == ")") {

        } else if (row == "and") {

        } else if (row == "or") {

        }
        
    }
    function DeleteWhere(column,type,value) {

        var jsonObj = eval("(" + $("#hidWhereJson").val() + ")");
        var result = false;

        var obj = { column: column, type: type, value: value };

        for (var i = 0; i < jsonObj.length; i++) {
            if (jsonObj[i].column == column && jsonObj[i].type == type && jsonObj[i].value == value) {
                result = true;
                jsonObj.splice(i, 1);
            }
        }
        $("#hidWhereJson").val(JSON.stringify(jsonObj));
        $("#datatable .data").remove();
        for (var i = 0; i < jsonObj.length; i++) {
            $("#datatable").append("<tr class=\"data\"><td>" + jsonObj[i].column + "</td><td>" + jsonObj[i].type + "</td><td>" + jsonObj[i].value + "</td><td>" + "<a href=\"javascript:;\" onclick=\"DeleteWhere('" + jsonObj[i].column + "','" + jsonObj[i].type + "','" + jsonObj[i].value + "')\">×</a>" + "</td></tr>");
        }
    }
</script>
</head>

<body class="mainbody">
<form id="form1" runat="server">


<!--内容-->

      <ul uk-tab>
        <li class="uk-active"><a class="" href="javascript:;">基本配置</a></li>
      </ul>

    <ul class="uk-switcher">
        <li>
<div class="tab-content">
  <dl>
    <dt>名称</dt>
    <dd><asp:TextBox ID="txtTitle" runat="server"  CssClass="uk-input" datatype="*2-100" sucmsg=" "></asp:TextBox> <span class="Validform_checktip">*标题备注，允许中文。</span></dd>
  </dl>
  <dl>
    <dt>管理员</dt>
    <dd>
      <div class="xm-select">
        <asp:DropDownList id="ddlManagers" runat="server" CssClass="uk-select" datatype="*" errormsg="请选择管理员" sucmsg=" "></asp:DropDownList>
          <asp:HiddenField ID="hidXmSelectddlManagers" runat="server" />
      </div>
    </dd>
  </dl>
  <dl>
    <dt>数据表</dt>
    <dd>
      <div class="rule-single-select">
        <asp:DropDownList id="ddlForm" runat="server" CssClass="uk-select" datatype="*" errormsg="请选择操作的表格！" sucmsg=" "></asp:DropDownList>
      </div>
    </dd>
  </dl>
  <dl>
    <dt>条件</dt>
    <dd>
        <asp:HiddenField ID="hidWhereJson" runat="server" Value="[]" />
        <table id="datatable" class="uk-table uk-table-responsive uk-table-divider">
            <tbody>
                <tr>
                    <td><asp:DropDownList id="ddlColumn" runat="server" CssClass="uk-select"></asp:DropDownList></td>
                    <td>
                        <asp:DropDownList id="ddlType" runat="server" CssClass="uk-select">
                            <asp:ListItem Value="Equal">= value</asp:ListItem>
                            <asp:ListItem Value="Like">like '%value%'</asp:ListItem>
                            <asp:ListItem Value="NoLike">not like '%value%'</asp:ListItem>

                            <asp:ListItem Value="GreaterThan">&gt; value</asp:ListItem>
                            <asp:ListItem Value="GreaterThanOrEqual">&gt;= value</asp:ListItem>
                            <asp:ListItem Value="LessThan">&lt; value</asp:ListItem>
                            <asp:ListItem Value="LessThanOrEqual">&lt;= value</asp:ListItem>

                            <asp:ListItem Value="In">In (value1,value2...)</asp:ListItem>
                            <asp:ListItem Value="NotIn">Not In (value1,value2...)</asp:ListItem>
                            <asp:ListItem Value="LikeLeft">like 'value%'</asp:ListItem>
                            <asp:ListItem Value="LikeRight">like '%value'</asp:ListItem>
                            <asp:ListItem Value="NoEqual">&lt;&gt; value</asp:ListItem>
                            <asp:ListItem Value="IsNullOrEmpty">value is null or value = ''</asp:ListItem>
                            <asp:ListItem Value="IsNot">is not</asp:ListItem>
                            <asp:ListItem Value="EqualNull">is null</asp:ListItem>
                        </asp:DropDownList>
                    </td>
                    <td><asp:TextBox ID="txtValue" runat="server"  CssClass="uk-input"></asp:TextBox></td>
                    <td>
                        <a href="javascript:;" onclick="AddWhere('row')" class="uk-button uk-button-default uk-button-small">添加</a>
<%--                        <a href="javascript:;" onclick="AddWhere('(')" class="uk-button uk-button-default uk-button-small">（</a>
                        <a href="javascript:;" onclick="AddWhere(')')" class="uk-button uk-button-default uk-button-small">）</a>
                        <a href="javascript:;" onclick="AddWhere('and')" class="uk-button uk-button-default uk-button-small">And</a>
                        <a href="javascript:;" onclick="AddWhere('or')" class="uk-button uk-button-default uk-button-small">Or</a>--%>
                    </td>
                </tr>
                <%
                    if(roleValues!=null)
                    {
                        if(roleValues.Count>0)
                        {
                            foreach(ByteSite.Entitys.dt_form_data_role_value v in roleValues)
                            {
                                %>
                <tr class="data">
                    <td><%=v.column %></td>
                    <td><%=v.type %></td>
                    <td><%=v.value %></td>
                    <td><a href="javascript:;" onclick="DeleteWhere('<%=v.column %>','<%=v.type %>','<%=v.value %>')">×</a></td></tr>
                <%
                            }
                        }
                    }
                    %>
            </tbody>
        </table>
    </dd>
  </dl>
  <dl>
    <dt>高级SQL模式</dt>
    <dd><asp:TextBox ID="txtSql" runat="server" TextMode="MultiLine"  CssClass="uk-textarea" Rows="5"></asp:TextBox></dd>
  </dl>
</div>
</li>
</ul>
<!--/内容-->

<!--工具栏-->
<div class="page-footer">
  <div class="btn-wrap">
    <asp:Button ID="btnSubmit" runat="server" Text="提交保存" CssClass="uk-button uk-button-primary " onclick="btnSubmit_Click" />
    <input name="btnReturn" type="button" value="取消返回" class="uk-button uk-button-default " onclick="javascript:history.back(-1);" />
  </div>
</div>
<!--/工具栏-->

</form>
</body>
</html>
